/***************************************************************
*  Copyright (c) 2007 by GroupMe! Team (www.groupme.net)
*  All rights reserved.
*
*  This file is part of the GroupMe! Project. Source code of 
*  this project is closed and redistribution of this code is
*  prohibited. 
*  
*  Contact: http://www.groupme.net
*
*  This copyright notice MUST APPEAR in all copies of the file!
***************************************************************/
package net.groupme.search.strategy.model;

/**
 * created on 10 Dec 2007
 * 
 * This class implements a GroupMe! Tag Assignment.
 * 
 * @author Fabian Abel, <a href="mailto:abel@l3s.de">abel@l3s.de</a>
 * @author last edited by: $Author: fabian $
 * 
 * @version $Revision: 1.4 $ $Date: 2008-11-17 15:43:45 $
 */
public class TASImpl implements TAS {

	private int userId = TAS.ID_NOT_SET;
	private int tagId = TAS.ID_NOT_SET;
	private int resourceId = TAS.ID_NOT_SET;
	private int groupId = TAS.ID_NOT_SET;
	private int id = TAS.ID_NOT_SET;
	private boolean directTAS = true;//false -> TAS wurde von Gruppe abgeleitet
	/**
	 * @param userId
	 * @param tagId
	 * @param resourceId
	 * @param groupId
	 */
	public TASImpl(int userId, int tagId, int resourceId, int groupId) {
		super();
		this.userId = userId;
		this.tagId = tagId;
		this.resourceId = resourceId;
		if(groupId > 0){
			this.groupId = groupId;
		}
	}
	
	/**
	 * @param userId
	 * @param tagId
	 * @param resourceId
	 * @param groupId
	 */
	public TASImpl(int id, int userId, int tagId, int resourceId, int groupId) {
		super();
		this.userId = userId;
		this.tagId = tagId;
		this.resourceId = resourceId;
		if(groupId > 0){
			this.groupId = groupId;
		}
		if(id > 0){
			this.id = id;
		}
	}
	/* (non-Javadoc)
	 * @see org.groupme.model.TAS#getGroupId()
	 */
	public int getGroupId() {
		return groupId;
	}
	/* (non-Javadoc)
	 * @see org.groupme.model.TAS#setGroupId(int)
	 */
	public void setGroupId(int groupId) {
		this.groupId = groupId;
	}
	/* (non-Javadoc)
	 * @see org.groupme.model.TAS#getResourceId()
	 */
	public int getResourceId() {
		return resourceId;
	}
	/* (non-Javadoc)
	 * @see org.groupme.model.TAS#setResourceId(int)
	 */
	public void setResourceId(int resourceId) {
		this.resourceId = resourceId;
	}
	/* (non-Javadoc)
	 * @see org.groupme.model.TAS#getTagId()
	 */
	public int getTagId() {
		return tagId;
	}
	/* (non-Javadoc)
	 * @see org.groupme.model.TAS#setTagId(int)
	 */
	public void setTagId(int tagId) {
		this.tagId = tagId;
	}
	/* (non-Javadoc)
	 * @see org.groupme.model.TAS#getUserId()
	 */
	public int getUserId() {
		return userId;
	}
	/* (non-Javadoc)
	 * @see org.groupme.model.TAS#setUserId(int)
	 */
	public void setUserId(int userId) {
		this.userId = userId;
	}
	/**
	 * @return the directTAS
	 */
	public boolean isDirectTAS() {
		return directTAS;
	}
	/**
	 * @param directTAS the directTAS to set
	 */
	public void setDirectTAS(boolean directTAS) {
		this.directTAS = directTAS;
	}
	/* (non-Javadoc)
	 * @see java.lang.Object#equals(java.lang.Object)
	 */
	@Override
	public boolean equals(Object obj) {
		if (obj instanceof TAS) {
			TAS tas = (TAS) obj;
			return this.userId == tas.getUserId() && this.tagId == tas.getTagId() && this.resourceId == tas.getResourceId() && this.groupId ==tas.getGroupId();
		}
		return false;
	}
	/* (non-Javadoc)
	 * @see java.lang.Object#toString()
	 */
	@Override
	public String toString() {
		return "user: " + this.userId + ", tag: " + this.tagId + ", resource: " + this.resourceId + ", group: " + this.groupId ;
	}
	/**
	 * This method returns the id of a TASImpl object.
	 * @return the id
	 */
	public int getId() {
		return id;
	}
	/**
	 * This method sets the id of a TASImpl object.
	 * @param id the id to set
	 */
	public void setId(int id) {
		this.id = id;
	}

	/* (non-Javadoc)
	 * @see java.lang.Object#hashCode()
	 */
	@Override
	public int hashCode() {
		return ("" + id + userId + tagId + resourceId).hashCode();
	}
}
